package edu.cityu.cs.hk.datastructures;
import java.util.Comparator;
import java.io.Serializable;

/**
 *  A default comparator, which uses the natural ordering
 *
 *  @author Michael Goodrich
 */
public class DefaultComparator implements Comparator, Serializable {
  public DefaultComparator() { /* default constructor */ }

  /** 
   * Compares a to b.
   *
   * @return a negative integer if <tt>a</tt> is less than <tt>b</tt>,
   * zero if <tt>a</tt> equals <tt>b</tt>, or a positive integer if
   * <tt>a</tt> is greater than <tt>b</tt>
   */
  public int compare(Object a, Object b) throws ClassCastException { 
    return ((Comparable) a).compareTo(b);
  }
}
